<div class="grid_15">
<?
$departmentObj = new department();
$instructorErrorClass = Rd_Layout::hasMessage('instructorMatchError') ? ' error' : '';
$instructorFieldValue = (
	$this->instructorFieldValue
	? "value=\"$this->instructorFieldValue\""
	: ''
);
$instructorValue = (
	$this->instructorValue
	? "value=\"$this->instructorValue\""
	: ''
);
$departmentErrorClass = Rd_Layout::hasMessage('departmentMatchError') ? ' error' : '';
$departmentFieldValue = (
	$this->departmentFieldValue
	? "value=\"$this->departmentFieldValue\""
	: ''
);
?>
<script>
	$(document).ready(function() {
		$('#instructorSearchField').autocomplete({
			source : rd.getBaseUrl() + 'json/autocomplete/instructororproxy/',
			minLength : 2,
			select : function(event,ui) {
				this.value = ui.item.label;
				$('#searchInstructorResult').val(ui.item.value);
				//this.form.submit();
				return false;
			}
		});
		$('#departmentSearchField').autocomplete({
			source : rd.getBaseUrl() + 'json/autocomplete/dept/',
			minLength : 2,
			select : function(event,ui) {
				this.value = ui.item.label;
				$('#searchDepartmentResult').val(ui.item.value);
				//this.form.submit();
				return false;
			}
		});
	});
</script>
<div class="cancelNavigation">[ <a href="./?cmd=viewCourseList">Cancel</a> ]</div>
<?php 
if (Account_Rd::atLeastFaculty()) { //#TODO use a config setting/plug-in detection to decide if it should say courses are automatically assigned
?>
	<div class="policyNotice">
		<p><strong>Instructors</strong>: Adding a class through this page will only 
		allow you to see that class as a student would. Classes that you are teaching 
		should show up automatically in your <a href="./?cmd=viewCourseList">My Courses</a> list. If you do not see your class under your My Courses list, you may:</p>
		<ul>
			<li>contact <a href="mailto:<?php print(Rd_Registry::get('supportEmail')); ?>">Reserves Staff</a> 
			for assistance in finding and setting up your course,</li>
			<li>or <a href="./?cmd=createClass">create a class</a> and manage enrollment manually.</li>
		</ul>
	</div>
<?php 		
}
?>
<div class="grid_7">
	<h2 class="formHeader grid_5">SEARCH BY INSTRUCTOR</h2>
	<form class="bordered clearing basicPadding bottomMargin" action="./" method="get" name="searchByInstructor">
		<input type="hidden" name="cmd" value="addClass" />
		<label class="blockLabel bottomHalfMargin<?php print($instructorErrorClass); ?>">
			<span class="labelTextShort">Instructor: </span>
			<input type="text" name="searchInstructor" id="instructorSearchField" <?php print($instructorFieldValue); ?> size="40" />
			<br/><span class="supplementText noMargin">Name</span>
			<?php if ($instructorErrorClass) { ?>	
				<span class="formAlertMessage supplementText failedText"><?php print(Rd_Layout::getMessage('instructorMatchError'));?></span>
			<?php } ?>
		</label>
		<input type="hidden" name="searchInstructorResult" id="searchInstructorResult" <?php print($instructorValue); ?>/>
		<input type="submit" name="searchCourseSubmit" value="Search Courses" />

	<?php if (count($this->instructorList) > 0) { ?>
		<h3 class="topMargin"> Matching Instructors</h3>
		<div>
			<ul class="discList">
		<?php foreach ($this->instructorList as $userId => $userDisplay) {?>
					<li><a href="./?cmd=addClass&searchInstructorResult=<?php print($userId) ;?>&searchInstructor=<?php print($this->instructorFieldValue);?>"><?php print($userDisplay); ?></a></li>
		<?php } ?>
			</ul>
		</div>
	<?php } ?>
	</form>
</div>
<div class="grid_7 prefix_1">
	<h2 class="formHeader grid_5">SEARCH BY DEPARTMENT</h2>
	<form class="bordered clearing basicPadding bottomMargin" action="./" method="get" name="searchByDepartment">
		<input type="hidden" name="cmd" value="addClass" />
		<label class="blockLabel bottomHalfMargin<?php print($departmentErrorClass); ?>">
			<span class="labelText">Department: </span>
			<input type="text" name="searchDepartment" id="departmentSearchField" <?php print($departmentFieldValue); ?> size="40" />
			<br/><span class="supplementText noMargin">Name or Abbreviation</span>
			<?php if ($departmentErrorClass) { ?>	
				<span class="formAlertMessage supplementText failedText"><?php print(Rd_Layout::getMessage('departmentMatchError'));?></span>
			<?php } ?>
		</label>
		<input type="submit" name="searchCourseSubmit" value="Search Courses" />
	</form>
</div>
</div>